import {MessageBox, Message} from 'element-ui'
// 私有属性，只在当前文件可用
const showMessage = Symbol('showMessage')
const showLLMessage = Symbol('showLLMessage')
export default class lltMessage {
	success(options, single = true) {
		this[showMessage]('success', options, single)
	}

	warning(options, single = true) {
		this[showMessage]('warning', options, single)
	}

	info(options, single = true) {
		this[showMessage]('info', options, single)
	}

	error(options, single = true) {
		this[showMessage]('error', options, single)
	}

	messageError(options, single = true) {
		this[showLLMessage]('error', options, single)
	}

	[showMessage](type, options, single) {
		let message = document.getElementsByClassName('el-message-box__wrapper');
		if (single) {
			// 关键代码，判断当前页是否有el-message标签，如果没有则执行弹窗操作
			if (document.getElementsByClassName('el-message-box').length === 0 || message[0].style.display=="none" ) {
				MessageBox(options)
			}
		} else {
			MessageBox(options)
		}
	}

	[showLLMessage](type, options, single) {
		let message = document.getElementsByClassName('el-message-box__wrapper');

		if (single) {
			// 关键代码，判断当前页是否有el-message标签，如果没有则执行弹窗操作
			if (document.getElementsByClassName('el-message-box').length === 0 || message[0].style.display=="none" ) {
				MessageBox(options)
			}
		} else {
			Message.error(options.message)
		}
	}
}
